/*************************************************************************
 *
 * $Id: data.h 33 2006-07-01 09:19:05Z alpov $
 * 
 *************************************************************************/         

#ifndef _DATA_H
#define _DATA_H

#define SENSOR_DESC_LEN     16
#define SENSOR_MAX_COUNT    16
#define MODE_DESC_LEN       16
#define MODE_MAX_COUNT      8

typedef struct {
    unsigned char sensor_index;     // 0..SENSOR_MAX_COUNT=15   read-write
    unsigned char id;               // 0..127                   read-write
    signed char contrast;           // 0..63                    read-write
} INTERNAL_DATA_DESCRIPTOR;

typedef struct {
    char sensor_desc[SENSOR_MAX_COUNT][SENSOR_DESC_LEN];
    signed int temperature[SENSOR_MAX_COUNT];
    unsigned char sensor_count;     // 0..SENSOR_MAX_COUNT=15   readonly

    char mode_desc[MODE_MAX_COUNT][MODE_DESC_LEN];
    unsigned char mode_count;       // 0..MODE_MAX_COUNT=7      readonly

    unsigned char mode;             // 0..mode_count=7          read-write

    signed char shift;              // -30..30                  read-write
    unsigned char shift_length;     // 0..30                    read-write

    unsigned char sw_mode;          // 0..mode_count=7          read-write
    unsigned long sw_datetime;      // 0..4294967296            read-write

    unsigned long now;              // 0..4294967296            read-write

    unsigned char message;          // 0..255                   readonly
    unsigned char io_state;         // bit                      readonly?
} SHARED_DATA_DESCRIPTOR;


extern Mutex DataLock;
extern INTERNAL_DATA_DESCRIPTOR idata;
extern SHARED_DATA_DESCRIPTOR sdata;

extern void ReadEepromData(void);
extern void WriteEepromData(void);

#endif
